home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / libraries / mui20dev.lha / MUI / Developer / C / Examples / Font.c < prev    next >
C/C++ Source or Header  |  1994-02-11  |  16KB  |  576 lines

  1. /*
  2.  
  3. Title:     Font
  4. Version:   0.08
  5. Author:    Matthias Scheler <tron@lyssa.ms.sub.org>
  6.            DICE Support by Stefan Becker <stefanb@pool.informatik.rwth-aachen.de>
  7. Copyright: (c) by Matthias Scheler, freely distributable with MUI
  8.  
  9. This is a replacment for Commodore's prefs program "Font" written with "MUI".
  10. It does the same as the original program, but is font sensitive and sizable
  11. (A preferences program which ignores it's own setting, strange ...).
  12.  
  13. Look at the source code, and you'll recognize that the code for the creation
  14. of the GUI is very short, thanks to Magic User Interface.
  15.  
  16. Thanks to Klaus Melchior for the nice icon.
  17.  
  18. Compile:
  19.   sc Font.c MCCONS STRMERGE UNSCHAR NOSTKCHK OPTIMIZE
  20.   slink FROM LIB:c.o Font.o LIB LIB:sc.lib LIB:amiga.lib SC SD ND TO Font
  21.  
  22. */
  23.  
  24. #include <intuition/intuitionbase.h>
  25. #include <libraries/asl.h>
  26. #include <libraries/gadtools.h>
  27. #include <libraries/iffparse.h>
  28. #include <libraries/mui.h>
  29. #include <workbench/icon.h>
  30. #include <workbench/startup.h>
  31. #include <prefs/font.h>
  32. #include <prefs/prefhdr.h>
  33.  
  34. #ifdef __SASC
  35. #include <proto/dos.h>
  36. #include <proto/exec.h>
  37. #include <proto/icon.h>
  38. #include <proto/iffparse.h>
  39. #include <proto/intuition.h>
  40. #include <proto/muimaster.h>
  41. struct IntuitionBase *IntuitionBase;
  42. struct Library *IconBase;
  43. extern struct Library *SysBase;
  44. #else
  45. #include <clib/alib_protos.h>
  46. #include <clib/dos_protos.h>
  47. #include <clib/exec_protos.h>
  48. #include <clib/icon_protos.h>
  49. #include <clib/iffparse_protos.h>
  50. #include <clib/intuition_protos.h>
  51. #include <clib/muimaster_protos.h>
  52. #include <pragmas/dos_pragmas.h>
  53. #include <pragmas/exec_pragmas.h>
  54. #include <pragmas/icon_pragmas.h>
  55. #include <pragmas/iffparse_pragmas.h>
  56. #include <pragmas/intuition_pragmas.h>
  57. #include <pragmas/muimaster_pragmas.h>
  58. extern struct Library *SysBase, *DOSBase, *IntuitionBase, *IconBase;
  59. #endif
  60.  
  61. #include <string.h>
  62. #include <stdlib.h>
  63.  
  64. struct Library *IFFParseBase,*MUIMasterBase;
  65.  
  66. #ifdef MAX
  67. #undef MAX
  68. #endif
  69. #ifdef MIN
  70. #undef MIN
  71. #endif
  72.  
  73. #ifdef __SASC
  74. #define MAX(a,b) __builtin_max(a,b)
  75. #define MIN(a,b) __builtin_min(a,b)
  76. #else
  77. #define MAX(a,b) ((a)>(b)?(a):(b))
  78. #define MIN(a,b) ((a)<(b)?(a):(b))
  79. #endif
  80.  
  81. #define VERSION "0.08"
  82.  
  83. char *Version = "$VER: Font " VERSION " (03.08.93)";
  84.  
  85. #define FONT_NUM (FP_SCREENFONT+1)
  86.  
  87. APTR AP_Font;
  88. APTR WI_Font;
  89. APTR TO_Font[FONT_NUM];
  90. APTR BT_Font[FONT_NUM],BT_Save,BT_Use,BT_Cancel;
  91.  
  92. #define ID_WBFONT      1L
  93. #define ID_SYSFONT     2L
  94. #define ID_SCREENFONT  3L
  95. #define ID_SAVE        4L
  96. #define ID_USE         5L
  97.  
  98. #define ID_OPEN       10L
  99. #define ID_SAVE_AS    11L
  100.  
  101. #define ID_DEFAULTS   20L
  102. #define ID_LAST_SAVED 21L
  103. #define ID_RESTORE    22L
  104.  
  105. #define ID_ICONS      30L
  106.  
  107. struct NewMenu MN_Font[] =
  108.  {
  109.   NM_TITLE,"Project",NULL,0,0L,NULL,
  110.    NM_ITEM,"Open...","O",0,0L,(APTR)ID_OPEN,
  111.    NM_ITEM,"Save As...","A",0,0L,(APTR)ID_SAVE_AS,
  112.    NM_ITEM,NM_BARLABEL,NULL,0,0L,NULL,
  113.    NM_ITEM,"Quit","Q",0,0L,(APTR)MUIV_Application_ReturnID_Quit,
  114.   NM_TITLE,"Edit",NULL,0,0L,NULL,
  115.    NM_ITEM,"Reset To Defaults","D",0,0L,(APTR)ID_DEFAULTS,
  116.    NM_ITEM,"Last Saved","L",0,0L,(APTR)ID_LAST_SAVED,
  117.    NM_ITEM,"Restore","R",0,0L,(APTR)ID_RESTORE,
  118.   NM_TITLE,"Settings",NULL,0,0L,NULL,
  119.    NM_ITEM,"Create Icons?","I",CHECKIT|CHECKED|MENUTOGGLE,0L,(APTR)ID_ICONS,
  120.   NM_END,NULL,NULL,0,0L,NULL
  121.  };
  122.  
  123. struct FontPrefs FontPrefs[FONT_NUM],RestorePrefs[FONT_NUM],StdFont =
  124.  {0L,0L,0L,0,0,1,0,JAM1,NULL,TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT,"topaz.font"};
  125.  
  126. char *ModeList[] = {"Mode","Text","Text+Field",NULL};
  127.  
  128. #define ENV_FILE    "ENV:Sys/Font.prefs"
  129. #define ENVARC_FILE "ENVARC:Sys/Font.prefs"
  130.  
  131. UWORD PutChar[2] = {0x16C0,0x4E75};
  132.  
  133. /* dirty hack to avoid assembler part :-)
  134.  
  135.    16C0: move.b d0,(a3)+
  136.    4E75: rts
  137. */
  138.  
  139. /* own sprintf() based on exec.library/RawDoFmt() to keep program short */
  140.  
  141. void SPrintF(char *Buffer,char *FormatString,...)
  142.  
  143. {
  144.  RawDoFmt (FormatString,(APTR)((LONG *)&FormatString+1L),(void *)PutChar,Buffer);
  145. }
  146.  
  147. /* load font preferences from a file */
  148.  
  149. LONG LoadPrefs(struct FontPrefs *FontPrefs,char *Name)
  150.  
  151. {
  152.  LONG Error;
  153.  struct IFFHandle *IFF;
  154.  
  155.  Error=ERROR_NO_FREE_STORE;
  156.  if (IFF=AllocIFF())
  157.   {
  158.    if (IFF->iff_Stream=(ULONG)Open(Name,MODE_OLDFILE))
  159.     {
  160.      InitIFFasDOS (IFF);
  161.      if ((Error=OpenIFF(IFF,IFFF_READ))==0L)
  162.       {
  163.        if ((Error=CollectionChunk(IFF,ID_PREF,ID_FONT))==0L)
  164.         if ((Error=StopOnExit(IFF,ID_PREF,ID_FORM))==0L)
  165.          if ((Error=ParseIFF(IFF,IFFPARSE_SCAN))==IFFERR_EOC)
  166.           {
  167.            struct CollectionItem *CItem;
  168.  
  169.            Error=0L;
  170.            CItem=FindCollection(IFF,ID_PREF,ID_FONT);
  171.            while (CItem)
  172.             {
  173.              struct FontPrefs *Ptr;
  174.  
  175.              Ptr=(struct FontPrefs *)CItem->ci_Data;
  176.              if ((CItem->ci_Size==sizeof(struct FontPrefs))&&
  177.                  (Ptr->fp_Type<FONT_NUM)) FontPrefs[Ptr->fp_Type]=*Ptr;
  178.  
  179.              CItem=CItem->ci_Next;
  180.             }
  181.           }
  182.  
  183.        CloseIFF (IFF);
  184.       }
  185.      Close ((BPTR)IFF->iff_Stream);
  186.     }
  187.    else Error=IoErr();
  188.  
  189.    FreeIFF (IFF);
  190.   }
  191.  return Error;
  192. }
  193.  
  194. /* write one "struct PrefHeader" and three "struct FontPrefs" to an IFF file */
  195.  
  196. LONG WritePrefsData(struct IFFHandle *IFF,struct FontPrefs *FontPrefs)
  197.  
  198. {
  199.  struct PrefHeader PrefHeader;
  200.  LONG Error,Index;
  201.  
  202.  if (Error=PushChunk(IFF,ID_PREF,ID_FORM,IFFSIZE_UNKNOWN)) return Error;
  203.  
  204.  PrefHeader.ph_Version=0;
  205.  PrefHeader.ph_Type=0;
  206.  PrefHeader.ph_Flags=0L;
  207.  if (Error=PushChunk(IFF,ID_PREF,ID_PRHD,sizeof(struct PrefHeader))) return Error;
  208.  if ((Error=WriteChunkBytes(IFF,&PrefHeader,sizeof(struct PrefHeader)))<0L) return Error;
  209.  if (Error=PopChunk(IFF)) return Error;
  210.  
  211.  for (Index=0L; Index<FONT_NUM; Index++)
  212.   {
  213.    if (Error=PushChunk(IFF,ID_PREF,ID_FONT,sizeof(struct FontPrefs))) return Error;
  214.    if ((Error=WriteChunkBytes(IFF,&FontPrefs[Index],sizeof(struct FontPrefs)))<0L) return Error;
  215.    if (Error=PopChunk(IFF)) return Error;
  216.   }
  217.  
  218.  return PopChunk(IFF);
  219. }
  220.  
  221. /* save font preferences to a file */
  222.  
  223. LONG SavePrefs(struct FontPrefs *FontPrefs,char *Name)
  224.  
  225. {
  226.  LONG Error;
  227.  struct IFFHandle *IFF;
  228.  
  229.  Error=ERROR_NO_FREE_STORE;
  230.  if (IFF=AllocIFF())
  231.   {
  232.    if (IFF->iff_Stream=(ULONG)Open(Name,MODE_NEWFILE))
  233.     {
  234.      InitIFFasDOS (IFF);
  235.      if (OpenIFF(IFF,IFFF_WRITE)==0L)
  236.       {
  237.        Error=WritePrefsData(IFF,FontPrefs);
  238.  
  239.        CloseIFF (IFF);
  240.       }
  241.      Close ((BPTR)IFF->iff_Stream);
  242.      if (Error) (void)DeleteFile(Name);
  243.     }
  244.    else Error=IoErr();
  245.  
  246.    FreeIFF (IFF);
  247.   }
  248.  return Error;
  249. }
  250.  
  251. /* get Intuition window pointer from a MUI window */
  252.  
  253. struct Window *GetWinPtr(APTR WI_Any)
  254.  
  255. {
  256.  struct Window *Window;
  257.  
  258.  Window=NULL;
  259.  get (WI_Any,MUIA_Window_Window,&Window);
  260.  return Window;
  261. }
  262.  
  263. /* fill in three "struct FontPrefs" with default values */
  264.  
  265. void DefaultFontPrefs(struct FontPrefs *FontPrefs)
  266.  
  267. {
  268.  LONG Index;
  269.  
  270.  for (Index=0L; Index<FONT_NUM; Index++)
  271.   {
  272.    FontPrefs[Index]=StdFont;
  273.    FontPrefs[Index].fp_Type=Index;
  274.   }
  275. }
  276.  
  277. /* update font display in font window */
  278.  
  279. void SetFontTO(APTR *TO_Font,struct FontPrefs *FontPrefs)
  280.  
  281. {
  282.  static char FontName[FONT_NUM][FONTNAMESIZE];
  283.  ULONG Index;
  284.  
  285.  for (Index=0L; Index<FONT_NUM; Index++)
  286.   {
  287.    SPrintF (FontName[FontPrefs[Index].fp_Type],"%s %ld",
  288.             FontPrefs[Index].fp_Name,
  289.             FontPrefs[Index].fp_TextAttr.ta_YSize);
  290.    set (TO_Font[Index],MUIA_Text_Contents,FontName[FontPrefs[Index].fp_Type]);
  291.   }
  292. }
  293.  
  294. /* select a font with the "asl.library */
  295.  
  296. LONG SelectFont(APTR ParentWindow,struct FontPrefs *FontPrefs,
  297.                           char *Title,LONG FixedWidthOnly,LONG PensAndMode)
  298.  
  299. {
  300.  struct FontRequester *FontRequester;
  301.  struct Window *Window;
  302.  LONG Result;
  303.  UBYTE Index,FrontPens[8],BackPens[8];
  304.  
  305.  if ((Window=GetWinPtr(ParentWindow))==NULL) return FALSE;
  306.  
  307.  for (Index=0L; Index<4L; Index++)
  308.   {
  309.    FrontPens[Index]=BackPens[Index]=Index;
  310.    FrontPens[7-Index]=BackPens[7-Index]=(1<<Window->WScreen->BitMap.Depth)-Index-1;
  311.   }
  312.  
  313.  if ((FontRequester=(struct FontRequester *)
  314.       MUI_AllocAslRequestTags(ASL_FontRequest,
  315.                               ASLFO_Window,Window,
  316.                               ASLFO_TitleText,Title,
  317.                               ASLFO_InitialHeight,MAX(128L,Window->WScreen->Height-128L),
  318.                               ASLFO_InitialName,FontPrefs->fp_Name,
  319.                               ASLFO_InitialSize,FontPrefs->fp_TextAttr.ta_YSize,
  320.                               ASLFO_InitialFrontPen,FontPrefs->fp_FrontPen,
  321.                               ASLFO_InitialBackPen,FontPrefs->fp_BackPen,
  322.                               ASLFO_InitialDrawMode,FontPrefs->fp_DrawMode,
  323.                               ASLFO_Flags,
  324.                                (FixedWidthOnly?FOF_FIXEDWIDTHONLY:0L)|
  325.                                (PensAndMode?(FOF_DOFRONTPEN|FOF_DOBACKPEN|FOF_DODRAWMODE):0L),
  326.                               ASLFO_MaxFrontPen,MIN(8L,1L<<Window->WScreen->BitMap.Depth),
  327.                               ASLFO_MaxBackPen,MIN(8L,1L<<Window->WScreen->BitMap.Depth),
  328.                               ASLFO_FrontPens,FrontPens,
  329.                               ASLFO_BackPens,BackPens,
  330.                               ASLFO_ModeList,ModeList,
  331.                               TAG_DONE))==NULL) return FALSE;
  332.  
  333.  set (ParentWindow,MUIA_Window_Sleep,TRUE);
  334.  Result=MUI_AslRequest((APTR)FontRequester,NULL);
  335.  set (ParentWindow,MUIA_Window_Sleep,FALSE);
  336.  
  337.  if (Result)
  338.   {
  339.    (void)strcpy(FontPrefs->fp_Name,FontRequester->fo_Attr.ta_Name);
  340.    FontPrefs->fp_TextAttr=FontRequester->fo_Attr;
  341.    FontPrefs->fp_TextAttr.ta_Name=NULL;
  342.  
  343.    if (PensAndMode)
  344.     {
  345.      FontPrefs->fp_FrontPen=FontRequester->fo_FrontPen;
  346.      FontPrefs->fp_BackPen=FontRequester->fo_BackPen;
  347.      FontPrefs->fp_DrawMode=FontRequester->fo_DrawMode;
  348.     }
  349.   }
  350.  
  351.  MUI_FreeAslRequest (FontRequester);
  352.  return Result;
  353. }
  354.  
  355. /* display an I/O error with muimaster.library/MUI_Request */
  356.  
  357. void ErrorReq(char *Name,LONG Error)
  358.  
  359. {
  360.  char DOSMsg[80],ReqText[256];
  361.  
  362.  if (Error>0L)
  363.   {
  364.    (void)Fault(Error,NULL,DOSMsg,80L);
  365.    (void)strcat(strcat(strcat(strcpy(ReqText,"Error accessing file\n"),Name),",\n"),DOSMsg);
  366.   }
  367.  else (void)strcat(strcpy(ReqText,"Error processing IFF file\n"),Name);
  368.  
  369.  (void)MUI_Request(AP_Font,NULL,0L,"Program Error","Ok",ReqText);
  370. }
  371.  
  372. /* main program */
  373.  
  374. int main(int argc, char *argv[])
  375.  
  376. {
  377.  struct DiskObject *DiskObject;
  378.  LONG Done,Index,Error;
  379.  
  380. /* open our libraries */
  381.  
  382. #ifndef _DCC
  383.  if ((IconBase=OpenLibrary(ICONNAME,36))==NULL) exit (20);
  384.  if ((IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",36))==NULL)
  385.   {
  386.    CloseLibrary (IconBase);
  387.  
  388.    exit (20);
  389.   }
  390. #endif
  391.  if ((IFFParseBase=OpenLibrary("iffparse.library",0))==NULL)
  392.   {
  393. #ifndef _DCC
  394.    CloseLibrary (&IntuitionBase->LibNode);
  395.    CloseLibrary (IconBase);
  396. #endif
  397.  
  398.    exit (20);
  399.   }
  400.  if ((MUIMasterBase=OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))==NULL)
  401.   {
  402.    CloseLibrary (IFFParseBase);
  403. #ifndef _DCC
  404.    CloseLibrary (&IntuitionBase->LibNode);
  405.    CloseLibrary (IconBase);
  406. #endif
  407.  
  408.    exit (20);
  409.   }
  410.  
  411. /* init preferences stuff */
  412.  
  413.  DefaultFontPrefs (FontPrefs);
  414.  if (Error=LoadPrefs(FontPrefs,ENV_FILE))
  415.   if (Error!=ERROR_OBJECT_NOT_FOUND) ErrorReq (ENV_FILE,Error);
  416.  (void)memcpy(RestorePrefs,FontPrefs,sizeof(RestorePrefs));
  417.  
  418. /* create GUI stuff */
  419.  
  420.  AP_Font=ApplicationObject,
  421.           MUIA_Application_Title,"Font",
  422.           MUIA_Application_Version,Version,
  423.           MUIA_Application_Copyright,"Copyright © 1993 by Matthias Scheler",
  424.           MUIA_Application_Author,"Matthias Scheler",
  425.           MUIA_Application_Description,"Font Prefs Program",
  426.           MUIA_Application_Base,"Font",
  427.           MUIA_Application_SingleTask,TRUE,
  428.           MUIA_Application_DiskObject,DiskObject=GetDiskObject("PROGDIR:Font"),
  429.           SubWindow,WI_Font=WindowObject,
  430.            MUIA_Window_Title,"Font Preferences",
  431.            MUIA_Window_ID,MAKE_ID('F','O','N','T'),
  432.            MUIA_Window_Menu,MN_Font,
  433.            WindowContents,VGroup,
  434.             Child,ColGroup(2),
  435.              GroupFrameT("Selected Fonts"),ReadListFrame,
  436.              Child, VSpace(0), Child, VSpace(0),
  437.              Child,Label("Workbench Icon Text:"),
  438.              Child,TO_Font[FP_WBFONT]=TextObject,End,
  439.              Child,Label("System Default Text:"),
  440.              Child,TO_Font[FP_SYSFONT]=TextObject,End,
  441.              Child,Label("Screen Text:"),
  442.              Child,TO_Font[FP_SCREENFONT]=TextObject,End,
  443.              Child, VSpace(0), Child, VSpace(0),
  444.             End,
  445.             Child,VSpace(3),
  446.             Child,BT_Font[FP_WBFONT]=SimpleButton("Select Workbench Icon Text..."),
  447.             Child,BT_Font[FP_SYSFONT]=SimpleButton("Select System Default Text..."),
  448.             Child,BT_Font[FP_SCREENFONT]=SimpleButton("Select Screen Text..."),
  449.             Child,VSpace(3),
  450.             Child,HGroup,
  451.              Child,BT_Save=KeyButton("Save",'s'),
  452.              Child,BT_Use=KeyButton("Use",'u'),
  453.              Child,BT_Cancel=KeyButton("Cancel",'c'),
  454.             End,
  455.            End,
  456.           End,
  457.          End;
  458.  
  459. /* Seen it ? No pixel counting or any sh*t like that */
  460.  
  461.  if (AP_Font==NULL)
  462.   {
  463.    if (DiskObject) FreeDiskObject (DiskObject);
  464.  
  465.    CloseLibrary (MUIMasterBase);
  466.    CloseLibrary (IFFParseBase);
  467. #ifndef _DCC
  468.    CloseLibrary (&IntuitionBase->LibNode);
  469.    CloseLibrary (IconBase);
  470. #endif
  471.  
  472.    exit (10);
  473.   }
  474.  
  475. /* now setup stuff for event handling */
  476.  
  477.  DoMethod (WI_Font,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  478.            AP_Font,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  479.  
  480.  for (Index=0L; Index<FONT_NUM; Index++)
  481.   DoMethod (BT_Font[Index],MUIM_Notify,MUIA_Pressed,FALSE,
  482.             AP_Font,2,MUIM_Application_ReturnID,ID_WBFONT+Index);
  483.  
  484.  DoMethod (BT_Save,MUIM_Notify,MUIA_Pressed,FALSE,
  485.            AP_Font,2,MUIM_Application_ReturnID,ID_SAVE);
  486.  DoMethod (BT_Use,MUIM_Notify,MUIA_Pressed,FALSE,
  487.            AP_Font,2,MUIM_Application_ReturnID,ID_USE);
  488.  DoMethod (BT_Cancel,MUIM_Notify,MUIA_Pressed,FALSE,
  489.            AP_Font,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  490.  
  491. /* cycle chain for keyboard control */
  492.  
  493.  DoMethod (WI_Font,MUIM_Window_SetCycleChain,
  494.            BT_Font[FP_WBFONT],BT_Font[FP_SYSFONT],BT_Font[FP_SCREENFONT],
  495.            BT_Save,BT_Use,BT_Cancel,NULL);
  496.  
  497. /* init display */
  498.  
  499.  SetFontTO (TO_Font,FontPrefs);
  500.  set (WI_Font,MUIA_Window_Open,TRUE);
  501.  
  502. /* event loop */
  503.  
  504.  Done=FALSE;
  505.  while (!Done)
  506.   {
  507.    ULONG ID,Signal;
  508.  
  509.    ID=DoMethod(AP_Font,MUIM_Application_Input,&Signal);
  510.    switch (ID)
  511.     {
  512. /* Quit (by close gadget, keyboard, menu, ARexx or Exchange ... doesn't matter) */
  513.      case MUIV_Application_ReturnID_Quit:
  514.       Done=TRUE;
  515.       break;
  516.  
  517. /* gadgets selected with keyboard or mouse */
  518.      case ID_WBFONT:
  519.       if (SelectFont(WI_Font,&FontPrefs[FP_WBFONT],
  520.                      "Select Workbench Icon Text",FALSE,TRUE)) SetFontTO (TO_Font,FontPrefs);
  521.       break;
  522.      case ID_SYSFONT:
  523.       if (SelectFont(WI_Font,&FontPrefs[FP_SYSFONT],
  524.                      "Select System Default Text",TRUE,FALSE)) SetFontTO (TO_Font,FontPrefs);
  525.       break;
  526.      case ID_SCREENFONT:
  527.       if (SelectFont(WI_Font,&FontPrefs[FP_SCREENFONT],
  528.                      "Select Screen Text...",FALSE,FALSE)) SetFontTO (TO_Font,FontPrefs);
  529.       break;
  530.  
  531.      case ID_SAVE:
  532.       if (Error=SavePrefs(FontPrefs,ENVARC_FILE))
  533.        {
  534.         ErrorReq (ENVARC_FILE,Error);
  535.         break;
  536.        }
  537.      case ID_USE:
  538.       set (WI_Font,MUIA_Window_Open,FALSE);
  539.       if (Error=SavePrefs(FontPrefs,ENV_FILE)) ErrorReq (ENV_FILE,Error);
  540.       Done=TRUE;
  541.       break;
  542.  
  543. /* handle menu entries */
  544.      case ID_DEFAULTS:
  545.       DefaultFontPrefs (FontPrefs);
  546.       SetFontTO (TO_Font,FontPrefs);
  547.       break;
  548.      case ID_LAST_SAVED:
  549.       if (Error=LoadPrefs(FontPrefs,ENVARC_FILE)) ErrorReq (ENVARC_FILE,Error);
  550.       else SetFontTO (TO_Font,FontPrefs);
  551.       break;
  552.      case ID_RESTORE:
  553.       (void)memcpy(FontPrefs,RestorePrefs,sizeof(FontPrefs));
  554.       SetFontTO (TO_Font,FontPrefs);
  555.     }
  556.  
  557.    if (!Done&&(Signal!=0L)) (void)Wait(Signal);
  558.   }
  559.  
  560. /* remove GUI stuff */
  561.  
  562.  MUI_DisposeObject (AP_Font);
  563.  if (DiskObject) FreeDiskObject (DiskObject);
  564.  
  565. /* close our libraries */
  566.  
  567.  CloseLibrary (MUIMasterBase);
  568.  CloseLibrary (IFFParseBase);
  569. #ifndef _DCC
  570.  CloseLibrary (&IntuitionBase->LibNode);
  571.  CloseLibrary (IconBase);
  572. #endif
  573.  
  574.  exit (0);
  575. }
  576.